package cn.com.homeyoda.aimate.aihealth.ui.message;

import android.content.Context;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.bean.MessageBean;
import cn.com.homeyoda.aimate.aihealth.bean.MessageListBean;
import cn.com.homeyoda.aimate.aihealth.bean.MessageTitleBean;

import java.util.List;

/**
 * Created By 刘纯贵
 * Created Time 2020/4/30
 */
public class MessageAdapter extends BaseQuickAdapter<MessageListBean.RowsBean, BaseViewHolder> {

    private Context mContext;
    public MessageAdapter(int layoutResId, @Nullable List<MessageListBean.RowsBean> data, Context context) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MessageListBean.RowsBean item) {

    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        holder.setText(R.id.title,getData().get(position).getTitle());
        holder.setText(R.id.content,getData().get(position).getJumpContent());
//        holder.setText(R.id.time,getData().get(position).getTime());
        Log.i("haha","MessageAdapter");
        if(getData().get(position).getStatus().equals("0")){
            holder.setVisible(R.id.status, true);
        }else{
            holder.setVisible(R.id.status, false);
        }

        if(getData().get(position).getType().equals("调查问卷")){
           holder.setBackgroundRes(R.id.type_img,R.mipmap.wenjuan_bg);
           holder.setBackgroundRes(R.id.type_icon,R.mipmap.wenjuan_icon);
        }else if(getData().get(position).getType().equals("健康干预")){
            holder.setBackgroundRes(R.id.type_img,R.mipmap.jk_bg);
            holder.setBackgroundRes(R.id.type_icon,R.mipmap.jk_icon);
        }else if(getData().get(position).getType().equals("检测")){
            holder.setBackgroundRes(R.id.type_img,R.mipmap.jc_bg);
            holder.setBackgroundRes(R.id.type_icon,R.mipmap.jc_icon);
        }
    }



    @Override
    public void setNewData(@Nullable List<MessageListBean.RowsBean> data) {
        super.setNewData(data);
    }
}
